# 数据库校验

import pymysql
from typing import Dict, Any


def query_db(sql: str, params: Dict = None) -> Any:
    conn = pymysql.connect(
        host="${ENV(DB_HOST)}",
        user="test",
        password="test123",
        database="shop_db"
    )
    try:
        with conn.cursor() as cursor:
            cursor.execute(sql, params or ())
            return cursor.fetchone()[0]
    finally:
        conn.close()

# 在测试中通过 ${query_db("SELECT...")} 调用
